<?php
/**
 * Created by PhpStorm.
 * User: sosyuki
 * Date: 2018/8/13
 * Time: 17:23
 */

namespace Drupal\distribution\ViewsController\handler\filter;


use views_handler_filter_field_list;

class ParentDistributionUsers extends views_handler_filter_field_list {

  public function get_value_options() {
    $users = user_load_multiple(FALSE);
    $roles = user_roles(TRUE);
    $options = [];
    foreach ($roles as $rid => $role) {
      foreach ($users as $user) {
        if (user_has_role($rid, $user)) {
          $options[$role][$user->uid] = format_username($user);
          continue;
        }
      }
    }
    $this->value_options = $options;
  }
}
